﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DTO;

namespace GUI
{
    public partial class FormCapNhatDonHang : Form
    {
        public FormCapNhatDonHang()
        {
            InitializeComponent();
        }
        //bien cuc bo:
        public string madonhang;
        public string run;
        //load combo
        private void loadComboBoxTinhTrang()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("text");
            dt.Columns.Add("value");
            dt.Rows.Add("Thành Công", "2");
            dt.Rows.Add("Hủy", "3");
            cmbTinhTrang.DisplayMember = "text";
            cmbTinhTrang.ValueMember = "value";
            cmbTinhTrang.DataSource = dt;
            cmbTinhTrang.SelectedIndex = 0;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            List<string> listRun = new List<string>();
            listRun.Add("Dirty read error");
            listRun.Add("Dirty read fix");
            listRun.Add("Lost update error");
            listRun.Add("Lost update fix");

            FormRun fr = new FormRun();
            fr.listRun = listRun;
            fr.ShowDialog();

            string run = fr.run;

            string tinhtrang = cmbTinhTrang.Text;
            bool kq = DonHangBUS.CapNhatDonHang(madonhang, tinhtrang, run);
            if (kq)
            {
                MessageBox.Show("Đã cập nhật.");
                this.Dispose();
            }
            else
            {
                MessageBox.Show("Hủy giao tác.");
            }

        }

        private void FormCapNhatDonHang_Load(object sender, EventArgs e)
        {
            lbMaDonHang.Text = madonhang;
            loadComboBoxTinhTrang();
        }
    }
}
